#!/bin/sh

brew install python@2
pip install --upgrade virtualenv 

# clonde TTlabel source
rm -rf /tmp/TTlabelSetup
mkdir /tmp/TTlabelSetup
cd /tmp/TTlabelSetup
curl https://codeload.github.com/tzutalin/TTlabel/zip/master --output TTlabel.zip
unzip TTlabel.zip
rm TTlabel.zip

# setup python3 space
virtualenv --system-site-packages  -p python3 /tmp/TTlabelSetup/TTlabel-py3
source /tmp/TTlabelSetup/TTlabel-py3/bin/activate
cd TTlabel-master

# build TTlabel app
pip install py2app
pip install PyQt5 lxml
make qt5py3
rm -rf build dist
python setup.py py2app -A
mv "/tmp/TTlabelSetup/TTlabel-master/dist/TTlabel.app" /Applications
# deactivate python3
deactivate
cd ../
rm -rf /tmp/TTlabelSetup
echo 'DONE'